import gc

import nmap


def saomiao(host,way):
    l = []
    nm = nmap.PortScanner()
    output = nm.scan(hosts=host, arguments=way)
    for result in output["scan"].values():
        if result["status"]["state"] == "up":
            try:
                host_list = result["addresses"]["ipv4"]
            except:
                host_list = ""
            try:
                vendor = result["vendor"]
            except:
                vendor = ""
            try:
                reason = result["status"]["reason"]
            except:
                reason = ""
            try:
                port = result["portused"]
            except:
                port = ""
            try:
                os = result["osmatch"]
            except:
                os = ""
            data = {"host":host_list,"vendor":vendor,"reason":reason,"port":port,"os":os}

        l.append(data)

        del result
        gc.collect()
    return l